declare boundary-space preserve;
declare option xdmp:mapping "false";

let $xml := xs:string(xdmp:get-request-field("xml"))
let $file := xdmp:get-request-field("file")
let $xml2 := xdmp:unquote(fn:string-join(("<xml>", $xml, "</xml>"),""),"",'repair-full')
let $save := xdmp:document-insert($file, document{$xml2})

return xdmp:redirect-response("/backoffice?msg=Saved")
